
//
//  XJSearchView.m
//  weiboOC
//
//  Created by 徐绩 on 16/4/18.
//  Copyright © 2016年 ayumi. All rights reserved.
//

#import "XJSearchView.h"

@implementation XJSearchView

-(void)awakeFromNib{

    UIImageView *searchIcon = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.searchTextField.bounds.size.height, self.searchTextField.bounds.size.height)];
    
    
    searchIcon.image = [UIImage imageNamed:@"searchbar_textfield_search_icon"];
    
    searchIcon.contentMode = UIViewContentModeCenter;

    self.searchTextField.leftView = searchIcon;
    self.searchTextField.leftViewMode = UITextFieldViewModeAlways;
    
    
}

#pragma mark - 点击取消按钮
- (IBAction)clickCancelBtn:(UIButton *)sender {
    
    self.searchTextFieldRightConstraint.constant = 0;
    [self.searchTextField resignFirstResponder];
    
    [UIView animateWithDuration:0.5 animations:^{
        
        [self layoutIfNeeded];
    }];
}

#pragma mark - 文本框开始编辑
- (IBAction)textFieldEditingBegin:(UITextField *)sender {

    self.searchTextFieldRightConstraint.constant = self.cancelBtn.bounds.size.width;
    [UIView animateWithDuration:0.5 animations:^{
        
        [self layoutIfNeeded];
    }];
}
@end
